<?php
require_once(dirname(__FILE__).'/mysql_full.class.php');
require_once(dirname(__FILE__).'/msg.class.php');
define('SESSION_KEY',"RONGSELF");
class Action extends MySql{
	/**
	 * 字符串过滤，只包含字母和数字
	 *
	 * */
	public function cleanInput($input) {
		//$clean = strtolower($input);
		$clean = preg_replace('/[^A-Za-z0-9_]/', '', $input);
		$clean = substr($clean, 0, 20);
		return $clean;
	}
	/**
	 * 字符串过滤，只包含数字
	 *
	 * */
	public function cleanOnlyNum($input) {
		$clean = preg_replace('/[^0-9]/', '', $input);
		return $clean;
	}
	/**
	 * 字符串过滤，只包含数字并不能为空
	 * */
	public function cleanParam($input) {
		$clean = $this->cleanOnlyNum($input);
		if ($clean) {

			return $clean;

		} else {

			$this->showMsg("index.php", "非法操作");
		}

	}
	/**
	 * 字符串过滤，字符串转义
	 *
	 * */
	public function StringInput($input) {

		return mysql_real_escape_string($input);

	}
	/**
	 * 返回包含结果集的二维数组
	 *
	 * */
	public function getResultArray($result_c) {

		$class_arr = array ();
		while ($row_o = $this->fetch_array($result_c)) {

/*			$arr = array (
				'id' => $row_o['id'],
				'f_id' => $row_o['f_id'],
				'news_name' => $row_o['news_name']
			);*/
			array_push($class_arr, $row_o);
		}
		return $class_arr;

	}
	/**
	 * 解析技能值字符串
	 *
	 * */
	public function analysisStr($str){
	$cut = explode(',',$str);
	$result_arr = array();
	foreach($cut as $val){

		$temp_arr = explode(':',$val);
		array_push($result_arr,$temp_arr);

	}
	return $result_arr;

}

}